﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectCityPage.aspx.cs"
    Inherits="WebApplication.Restricted.Modal.SelectCityPage" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="CitiesGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="CitiesGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="CitiesGrid" runat="server" AllowFilteringByColumn="True"
        AllowPaging="True" AllowSorting="True" GridLines="None" Skin="WebBlue" DataSourceID="CitiesEntityDataSource">
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="Id" ClientDataKeyNames="Id,Name,ProvinceName"
            DataSourceID="CitiesEntityDataSource">
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" SortExpression="Id"
                    UniqueName="Id">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name"
                    UniqueName="Name">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ProvinceName" HeaderText="Województwo" SortExpression="ProvinceName"
                    UniqueName="ProvinceName">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <Selecting AllowRowSelect="true" />
            <ClientEvents OnRowSelected="RowSelected" />
        </ClientSettings>
    </telerik:RadGrid>
    <asp:EntityDataSource ID="CitiesEntityDataSource" runat="server" ConnectionString="name=MerchModelEntities"
        DefaultContainerName="MerchModelEntities" CommandText="select city.Id as Id, city.Name as Name, province.Name as ProvinceName from MerchModelEntities.City as city join MerchModelEntities.Province as province on city.Province = province"
        Select="it.[Id], it.[Name], it.[ProvinceName]" OrderBy="it.[Id]">
    </asp:EntityDataSource>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script type="text/javascript">
            function RowSelected(sender, eventArgs) {
                var city = new Object();
                city.Id = eventArgs.getDataKeyValue("Id");
                city.Name = eventArgs.getDataKeyValue("Name");
                city.Province = new Object();
                city.Province.Name = eventArgs.getDataKeyValue("ProvinceName");
                window.frameElement.radWindow.close(city);
            }
        </script>

    </telerik:RadCodeBlock>
    </form>
</body>
</html>
